package cn.java86.myschool.service;

import cn.java86.myschool.dao.StudentDao;
import cn.java86.myschool.entity.Page;
import cn.java86.myschool.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
@Service
public class StudentService  implements IStudentService{
    @Autowired
    private StudentDao studentDao;

    @Override
    public int add(Student s) {
        return studentDao.add(s);
    }

    @Override
    public int update(Student s) {
        return studentDao.update(s);
    }

    @Override
    public int del(long stuno) {
        return studentDao.del(stuno);
    }

    @Override
    public Student get(long stuno) {
        return studentDao.get(stuno);
    }

    @Override
    public int dels(long[] ids) {
        return studentDao.dels(ids);
    }

    @Override
    public Page<Student> paging(int pageNo, int pageSize, String sname, String qq, String phone, Date enterStart, Date enterEnd) {
        List<Student> list = studentDao.paging(pageNo, pageSize, sname, qq, phone, enterStart, enterEnd);
        long total = studentDao.pageTotal(sname, qq, phone, enterStart, enterEnd);
        return new Page<Student>(list,pageNo,total,pageSize);
    }

    @Override//true表示手机号已经存在
    public boolean checkPhone(String phone) {
        return this.studentDao.checkPhone(phone)!=null;
    }
}
